//
//  TransferResultViewController.m
//  PigMarket
//
//  Created by mac on 2019/5/8.
//  Copyright © 2019 felix.pigmarket.oc. All rights reserved.
//

#import "TransferResultViewController.h"
#import "HButtonView.h"
#import "TransferManagerViewController.h"

@interface TransferResultViewController ()
/**
 succImg
 */
@property (nonatomic , strong) HButtonView *succImg;
/**
 tips
 */
@property (nonatomic , strong) UILabel *tips;

/**
 checkTransferBtn
 */
@property (nonatomic , strong) UIButton *checkTransferBtn;
/**
 backAdopted
 */
@property (nonatomic , strong) UIButton *backAdoptedBtn;
@end

@implementation TransferResultViewController


#pragma mark - view life cycle
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"转让成功";
    [self setUpView];
}

#pragma mark - init method
- (void)setUpView {
    [self initView];
    [self initLayout];
    [self initAction];
    [self initData];
}


- (void)initView {
    [self.view addSubview:self.succImg];
    [self.view addSubview:self.tips];
    [self.view addSubview:self.checkTransferBtn];
    [self.view addSubview:self.backAdoptedBtn];
}



- (void) initLayout {
    [self.succImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view.mas_centerX);
        make.top.mas_equalTo([self scaleWithOrginalSize:70]);
        make.size.mas_equalTo(CGSizeMake([self scaleWithOrginalSize:80], [self scaleWithOrginalSize:120]));
    }];
    [self.tips mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.succImg.mas_bottom).offset(10);
        make.centerX.mas_equalTo(self.view.mas_centerX);
        make.height.mas_equalTo([self scaleWithOrginalSize:20]);
    }];
    [self.checkTransferBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.tips.mas_bottom).offset([self scaleWithOrginalSize:50]);
        make.left.mas_equalTo(52 * [JTool getScreenWidthScale]);
        make.size.mas_equalTo(CGSizeMake([self scaleWithOrginalSize:126], [self scaleWithOrginalSize:36]));
    }];
    [self.backAdoptedBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.checkTransferBtn.mas_top);
        make.right.mas_equalTo([self scaleWithOrginalSize:-52]);
        make.size.mas_equalTo(CGSizeMake([self scaleWithOrginalSize:126], [self scaleWithOrginalSize:36]));
    }];
}


- (CGFloat)scaleWithOrginalSize:(CGFloat)size {
    return size * [JTool getScreenWidthScale];
}


- (void) initAction {
    [self.checkTransferBtn addTarget:self action:@selector(checkTransferTapped) forControlEvents:UIControlEventTouchUpInside];
    [self.backAdoptedBtn addTarget:self action:@selector(backAdoptedTapped) forControlEvents:UIControlEventTouchUpInside];
}



- (void)initData {
    
}


#pragma mark - delegate

#pragma mark - target action

- (void)checkTransferTapped {
 
    [self.navigationController pushViewController:[[TransferManagerViewController alloc] init] animated:YES];
}


- (void)backAdoptedTapped {
    //刷新我的领养数据
    [[NSNotificationCenter defaultCenter] postNotificationName:NotificationTransferChange object:nil];

//    [self.navigationController removeViewControllerWithName:@"TransferTypeViewController"];
//    [self.navigationController removeViewControllerWithName:@"TransferInfoViewController"];
//    [self.navigationController removeViewControllerWithName:@"InputTransferInfoViewController"];
    [self.navigationController popViewControllerAnimated:YES];
}


#pragma mark - private method

#pragma mark - getter and setter
- (HButtonView *)succImg {
    if (!_succImg) {
        UIImageView *iconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"meat_complaints_selected"]];
        UILabel *titleLabel = [[UILabel alloc] init];
        titleLabel.text = @"转让成功";
        titleLabel.font = [UIFont systemFontOfSize:21];
        titleLabel.textColor = [UIColor textBlackColor];
        
        _succImg = [[HButtonView alloc] initWithTopIcon:iconView title:titleLabel];
    }
    return _succImg;
}


- (UILabel *)tips {
    if (!_tips) {
        _tips = [[UILabel alloc] init];
        _tips.textColor = [UIColor colorWithHexString:@"#999999"];
        _tips.font = [UIFont systemFontOfSize:13];
        _tips.text = @"转让成功，对方会已短信方式收到通知";
    }
    return _tips;
}


- (UIButton *)checkTransferBtn {
    if (!_checkTransferBtn) {
        _checkTransferBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_checkTransferBtn setTitle:@"查看转让" forState:UIControlStateNormal];
        [_checkTransferBtn setTitleColor:[UIColor colorWithHexString:@"#454545"] forState:UIControlStateNormal];
        _checkTransferBtn.titleLabel.font = [UIFont largerFont];
        _checkTransferBtn.layer.borderColor = [UIColor colorWithHexString:@"#D8D8D8"].CGColor;
        _checkTransferBtn.layer.borderWidth = 1;
        _checkTransferBtn.layer.cornerRadius = 18;
        _checkTransferBtn.layer.borderWidth = 1;
    }
    return _checkTransferBtn;
}


- (UIButton *)backAdoptedBtn {
    if (!_backAdoptedBtn) {
        _backAdoptedBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_backAdoptedBtn setTitle:@"回到领养" forState:UIControlStateNormal];
        [_backAdoptedBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _backAdoptedBtn.titleLabel.font = [UIFont largerFont];
        [_backAdoptedBtn setBackgroundImage:[UIImage imageNamed:@"pay_result_btn_bg"] forState:UIControlStateNormal];
    }
    return _backAdoptedBtn;
}


@end
